// import { Action, action } from 'easy-peasy';
import { Websocket } from '@hooks/WebSocket';
import { create } from 'zustand'
import { immer } from "zustand/middleware/immer"


export interface SocketStore {
    instance: Websocket | null;
    connected: boolean;
}

export const useSocketStore = create(immer(
    () => ({
        instance: null,
        connected: false,
    } as SocketStore)
))

export const setInstance = (payload: any) => {
    useSocketStore.setState((state) => {
        state.instance = payload
    })
}

export const setConnectionState = (payload: boolean) => {
    useSocketStore.setState((state) => {
        state.connected = payload
    })
}
